import React, { Component } from 'react';

//加载模块样式
import { Selectstate_style as styles } from '../../../../../styles';

import {
    View,
    Text,
    TouchableOpacity,
    ScrollView,
} from 'react-native';

var Dimensions = require('Dimensions');
var width = Dimensions.get('window').width;          //获取屏幕宽度

import Condition from './condition';
import Selecttwo from '../every/selecttwo';

export default class Select_state extends Component {

    constructor(props) {
        super(props);
        this.state = {
            sel_state: 0,
        }
    }
    render() {
        return (
            <View style={[styles.sel_all, { width: width * 1 }]}>
                <View style={styles.sel_out}>
                    <View style={[styles.sel_in, { width: width * 0.68 }]}>

                        <TouchableOpacity activeOpacity={1}
                            onPress={() => { this.setState({ sel_state: 0 }) }} style={styles.area}>
                            {this.state.sel_state == 0 ? <Text style={styles.onfocus}>历史记录</Text>
                                : <Text style={styles.unfocus}>历史记录</Text>}
                            {this.state.sel_state == 0 ? <View style={styles.sel_line} />
                                : <View style={styles.sel_line2} />}
                        </TouchableOpacity>

                        <TouchableOpacity activeOpacity={1}
                            onPress={() => { this.setState({ sel_state: 1 }) }} style={styles.area}>
                            {this.state.sel_state == 1 ? <Text style={styles.onfocus}>搜索条件</Text>
                                : <Text style={styles.unfocus}>搜索条件</Text>}
                            {this.state.sel_state == 1 ? <View style={styles.sel_line} /> :<View style={styles.sel_line2} />}
                        </TouchableOpacity>
                    </View>
                </View>

                <ScrollView>
                    {this.state.sel_state == 0 ?
                        <Selecttwo
                            delhis={this.props.delhis.bind(this)}
                            hopstate={this.props.hopstate.bind(this)}
                            _likeStr={this.props._likeStr.bind(this)}
                            dataSource={this.props.dataSource}
                            actions={this.props.actions}
                            workspace={this.props.workspace}
                        />
                        :
                        <Condition
                            addfields={this.props.addfields.bind(this)}
                            delefields={this.props.delefields.bind(this)}
                            _salary={this.props._salary.bind(this)}
                            _fadate={this.props._fadate.bind(this)}
                        />
                    }
                </ScrollView>

            </View >
        )
    }
}